package GraphTheory;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

class Solver1280
{	int n,m;
	boolean[] Visited;
	int[] List;
	List<List<Integer>> Rec;
	
	public void Input() throws IOException
	{	StreamTokenizer in=new StreamTokenizer(new InputStreamReader(System.in));
		in.nextToken();n=(int)in.nval;
		in.nextToken();m=(int)in.nval;
		Visited=new boolean[n+1];Arrays.fill(Visited,false);
		List=new int[n+1];
		Rec=new ArrayList<List<Integer>>(n+1);
		for (int i=0;i<=n;i++)
			Rec.add(new LinkedList<Integer>());
		for (int i=1;i<=m;i++)
		{	in.nextToken();int n1=(int)in.nval;
			in.nextToken();int n2=(int)in.nval;
			Rec.get(n2).add(n1);
		}
		for (int i=1;i<=n;i++)
		{	in.nextToken();List[i]=(int)in.nval;
		}
	}
	public void Solve() throws IOException
	{	Input();
		for (int i=1;i<=n;i++)
		{	for (Integer f:Rec.get(List[i]))
				if (Visited[f]==false)
				{	Output(false);return;
				}
			Visited[List[i]]=true;
		}
		Output(true);
	}
	public void Output(boolean b)
	{	if (b) System.out.println("YES"); else System.out.println("NO");
	}
}
public class P1280
{	public static void main(String[] args) throws IOException
	{	Solver1280 solver=new Solver1280();
		solver.Solve();
	}
}
